package com.guigu.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.BusinessesService;
import com.guigu.mapper.BusinessesMapper;
import com.guigu.pojo.Businesses;
import com.guigu.pojo.FrontUser2;
import com.guigu.vo.BusinessesVo;
import com.guigu.vo.Pojo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BusinessesServiceImpl extends ServiceImpl<BusinessesMapper, Businesses> implements BusinessesService {
    @Autowired
    private BusinessesMapper businessesMapper;
    @Override
    public PageInfo<Businesses> selectAll(BusinessesVo vo, int pageNo, int pageSize) {
        PageHelper.startPage(pageNo,pageSize);
        List<Businesses> businesses = businessesMapper.selectAll(vo);
        PageInfo<Businesses> businessesPageInfo = new PageInfo<>(businesses);
        return businessesPageInfo;
    }

    @Override
    public Businesses One(int id) {
        return businessesMapper.One(id);
    }

    @Override
    public Pojo<FrontUser2> getPage(int pageNum, int pageSize, BusinessesVo vo) {
        PageHelper.startPage(pageNum,pageSize);
        List<FrontUser2> frontUser2s = businessesMapper.select(vo, pageNum, pageSize);
        PageInfo<FrontUser2> frontUser2PageInfo = new PageInfo<>(frontUser2s);
        Pojo<FrontUser2> frontUser2Pojo = new Pojo<>();
        frontUser2Pojo.setRows(frontUser2PageInfo.getList());
        frontUser2Pojo.setTotal(frontUser2PageInfo.getTotal());
        return frontUser2Pojo;
    }

}
